home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / lib / mntc6846.zoo / patch / sftodf.s < prev    next >
Encoding:
Text File  |  1994-11-14  |  1.5 KB  |  52 lines

  1.  ! C68 4 byte floating point => 8 byte floating point conversion routine
  2.  !-----------------------------------------------------------------------------
  3.  ! ported to 68000 by Kai-Uwe Bloem, 12/89
  4.  !  #1  original author: Peter S. Housel 06/03/89
  5.  !  #2    added support for denormalized numbers            -kub-, 01/90
  6.  !  #3  Redid register usage, and then added wrapper routine
  7.  !    to provide C68 IEEE compatibility    Dave & Keith Walker    02/92
  8.  !  #4  Changed entry/exit code for C68 compatibility
  9.  !    Removed ACK entry points                -djw-    09/93
  10.  !-----------------------------------------------------------------------------
  11.  
  12.     .sect .text
  13.  
  14.     .define    .Xsftodf
  15.  
  16. BIAS4    =    0x7F - 1
  17. BIAS8    =    0x3FF - 1
  18.  
  19. !----------------------------------------
  20. !    sp    Return address
  21. !    sp+4    address of result
  22. !    sp+8    address of value
  23. !----------------------------------------
  24. .Xsftodf:
  25.     move.l    4(sp),a1    ! result address
  26.     move.l    8(sp),a0    ! value address
  27.     move.l    (a0),(a1)    ! move across value
  28.     move.l  #0,4(a1)
  29.  
  30.     move.w    (a1),d0        ! extract exponent
  31.     move.w    d0,d2        ! extract sign
  32.     lsr.w    #7,d0
  33.     and.w    #0xff,d0    ! kill sign bit (exponent is 8 bits)
  34.  
  35.     move.w    d2,d1
  36.     and.w    #0x7f,d1    ! remove exponent from mantissa
  37.     tst.w    d0        ! check for zero exponent - no leading "1"
  38.     beq    0f        ! for denormalized numbers
  39.     or.w    #0x80,d1    ! restore implied leading "1"
  40.     bra    1f
  41. 0:    add.w    #1,d0        ! "normalize" exponent
  42. 1:    move.w    d1,(a1)
  43.  
  44.     add.w    #BIAS8-BIAS4-3,d0    ! adjust bias, account for shift
  45.     clr.w    d1        ! dummy rounding info
  46.     jsr    .Xnorm8
  47.  
  48.     move.l    (sp)+,a0    ! get return address
  49.     add.l    #8,sp        ! remove parameters from stack
  50.     jmp    (a0)        ! ... and return
  51.  
  52.